package com.ideal.manage.esms.controller.diagnostic;

import com.ideal.manage.esms.bean.DTO.PageDto;
import com.ideal.manage.esms.bean.diagnostic.Algorithm;
import com.ideal.manage.esms.bean.diagnostic.Diagnostic;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Controller
@RequestMapping("diagnostic")
public class AlgorithmController {

    /**
     * 算法列表请求
     *
     * @param model
     */
    @RequestMapping("diagnostic_algorithm_manager")
    public void diagnosticAlgorithmManager(Model model) {

    }

    /**
     * 设备算法数据请求
     * @param pageNum
     * @param request
     * @return
     */
    @RequestMapping("algorithm_data")
    @ResponseBody
    public PageDto algorithmData(int pageNum, HttpServletRequest request) {

        PageDto pageDto = new PageDto();
        pageDto.setTotal(2L);

        List<Algorithm> algorithms = new ArrayList<>();

        Algorithm algorithm1 = new Algorithm();
        algorithm1.setAlgorithmName("电池包SOC诊断");
        algorithm1.setChildAlgorithm("电池包SOC诊断(1#~8#电池包)|电池包SOC诊断(9#~10#电池包)");
        algorithm1.setCondition("单体电压压差>3V");
        algorithm1.setDeployTime(new Date());
        algorithm1.setDiagnosticEquipment("1#~8#电池包");
        algorithm1.setProcess("1.恒流充电10s...");
        algorithm1.setReverseControl("1");
        algorithm1.setStatus("2");
        algorithm1.setVersion("1.0");
        algorithms.add(algorithm1);

        Algorithm algorithm2 = new Algorithm();
        algorithm2.setAlgorithmName("循环次数诊断");
        algorithm2.setCondition("单体电压压差>4V");
        algorithm2.setDeployTime(new Date());
        algorithm2.setDiagnosticEquipment("所有电池包");
        algorithm2.setReverseControl("2");
        algorithm2.setStatus("1");
        algorithm2.setVersion("1.0");
        algorithms.add(algorithm2);

        pageDto.setRows(algorithms);
        return pageDto;
    }

    @RequestMapping("algorithm_add")
    public void algorithmAdd(Model model){

    }
}
